Optimal. Leaf size=68 \[ -\frac{a \sin (x)}{a^2+b^2}-\frac{b \cos (x)}{a^2+b^2}-\frac{a^2 \tanh ^{-1}\left (\frac{b \cos (x)-a \sin (x)}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.0778495, antiderivative size = 68, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 4, integrand size = 16, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.25, Rules used = {3099, 3074, 206, 2638} \[ -\frac{a \sin (x)}{a^2+b^2}-\frac{b \cos (x)}{a^2+b^2}-\frac{a^2 \tanh ^{-1}\left (\frac{b \cos (x)-a \sin (x)}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 3099
Rule 3074
Rule 206
Rule 2638
Rubi steps
\begin{align*} \int \frac{\sin ^2(x)}{a \cos (x)+b \sin (x)} \, dx &=-\frac{a \sin (x)}{a^2+b^2}+\frac{a^2 \int \frac{1}{a \cos (x)+b \sin (x)} \, dx}{a^2+b^2}+\frac{b \int \sin (x) \, dx}{a^2+b^2}\\ &=-\frac{b \cos (x)}{a^2+b^2}-\frac{a \sin (x)}{a^2+b^2}-\frac{a^2 \operatorname{Subst}\left (\int \frac{1}{a^2+b^2-x^2} \, dx,x,b \cos (x)-a \sin (x)\right )}{a^2+b^2}\\ &=-\frac{a^2 \tanh ^{-1}\left (\frac{b \cos (x)-a \sin (x)}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}}-\frac{b \cos (x)}{a^2+b^2}-\frac{a \sin (x)}{a^2+b^2}\\ \end{align*}
Mathematica [A] time = 0.155249, size = 62, normalized size = 0.91 \[ \frac{2 a^2 \tanh ^{-1}\left (\frac{a \tan \left (\frac{x}{2}\right )-b}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}}-\frac{a \sin (x)+b \cos (x)}{a^2+b^2} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A] time = 0.081, size = 84, normalized size = 1.2 \begin{align*} 2\,{\frac{-a\tan \left ( x/2 \right ) -b}{ \left ({a}^{2}+{b}^{2} \right ) \left ( \left ( \tan \left ( x/2 \right ) \right ) ^{2}+1 \right ) }}+8\,{\frac{{a}^{2}}{ \left ( 4\,{a}^{2}+4\,{b}^{2} \right ) \sqrt{{a}^{2}+{b}^{2}}}{\it Artanh} \left ( 1/2\,{\frac{2\,a\tan \left ( x/2 \right ) -2\,b}{\sqrt{{a}^{2}+{b}^{2}}}} \right ) } \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] time = 0.515675, size = 350, normalized size = 5.15 \begin{align*} \frac{\sqrt{a^{2} + b^{2}} a^{2} \log \left (-\frac{2 \, a b \cos \left (x\right ) \sin \left (x\right ) +{\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - 2 \, a^{2} - b^{2} + 2 \, \sqrt{a^{2} + b^{2}}{\left (b \cos \left (x\right ) - a \sin \left (x\right )\right )}}{2 \, a b \cos \left (x\right ) \sin \left (x\right ) +{\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + b^{2}}\right ) - 2 \,{\left (a^{2} b + b^{3}\right )} \cos \left (x\right ) - 2 \,{\left (a^{3} + a b^{2}\right )} \sin \left (x\right )}{2 \,{\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F(-2)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: AttributeError} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A] time = 1.25161, size = 127, normalized size = 1.87 \begin{align*} -\frac{a^{2} \log \left (\frac{{\left | 2 \, a \tan \left (\frac{1}{2} \, x\right ) - 2 \, b - 2 \, \sqrt{a^{2} + b^{2}} \right |}}{{\left | 2 \, a \tan \left (\frac{1}{2} \, x\right ) - 2 \, b + 2 \, \sqrt{a^{2} + b^{2}} \right |}}\right )}{{\left (a^{2} + b^{2}\right )}^{\frac{3}{2}}} - \frac{2 \,{\left (a \tan \left (\frac{1}{2} \, x\right ) + b\right )}}{{\left (a^{2} + b^{2}\right )}{\left (\tan \left (\frac{1}{2} \, x\right )^{2} + 1\right )}} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]